import { reqCategoryList,reqGetBannerList,reqFloorList } from '@/api';
const state = {
    categoryList:[],
    bannerList:[],
    floorList:[]
};
const mutations = {
    CATEGORYLIST(state,categoryList){
        state.categoryList=categoryList.slice(0,16)
    },
    GETBANNERYLIST(state,bannerList){
        state.bannerList=bannerList
    },
    REQFLOORLIST(state,floorList){
        // //console.log('修改数据');
        state.floorList=floorList
    }
};
const actions = {
    //通过api 接口函数调用
    async categoryList({commit}) {
        let result = await reqCategoryList()
        //    //console.log(result);
        if(result.code==200){
            commit('CATEGORYLIST',result.data)
        }
    },
    //轮播
    async getBannerList({commit}){
        let result =await reqGetBannerList();
        // //console.log(result);
        if(result.code==200){
            commit('GETBANNERYLIST',result.data)
        }
    },
    //获取floor数据
    async getFloorList({commit}){
        // //console.log('获取数据');
        let result =await  reqFloorList();
        // //console.log(result);
        if(result.code==200){
            commit('REQFLOORLIST',result.data)
        }
    },
};
const getters = {};
export default {
    state,
    mutations,
    actions,
    getters,
}